import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    coach:[],
    name:window.sessionStorage.getItem('name'),
  },
  getters: {

  },
  mutations: {
    addCoach(state,item){
      state.coach.push(item)
    },
    delCoach(state,id){
      state.coach.map((v,i)=>{
        if(v.c_id==id){
          state.coach.splice(i,1)
        }
      })
    },
    userLogin(state,payload){
      state.name=payload
      // 需要持久化存储，还需要将用户名存入sessionStorage
      sessionStorage.setItem('name',payload)
    },
      loginOut(state,payload){
        state.name=''//将vues中的数据清空
        sessionStorage.clear()//将sessionStorage中的数据清空
      }
  },
  actions: {
  },
  modules: {
  }
})
